#include "level2.h"

Level2::Level2(QWidget *parent)
    : LevelScene(QPixmap(RESOURCE_DIR + "/Rose_Present_Map.png"),QImage(RESOURCE_DIR + "/Rose_Present_Mask.png"), parent)
{
    //buildingImage = new GameBackground(QPixmap(RESOURCE_DIR + "/Rose_Present_Buildings.png"),mainScene);
   // buildingImage->setZValue(0);

    // Add the tools
    quarantineTool = addTool(QString("Quarantien (Place road block)"),RESOURCE_DIR + "/buttons/Kit_Quarantine.png");
    sterilizationTool = addTool(QString("Sterilize building"),RESOURCE_DIR + "/buttons/Dean_Sterilize.png");
    vacceneTool = addTool(QString("Vaccenate people in building"),RESOURCE_DIR + "/buttons/Kit_Pills.png");
    antiviralTool = addTool(QString("Prescribe building antiviral drugs"),RESOURCE_DIR + "/buttons/Kit_Pills.png");
    gammaglobulinTool = addTool(QString("Prescribe building Gammaglobulians"),RESOURCE_DIR + "/buttons/Kit_Pills.png");

    // Add one story houses
    QPointF house1Info[68][2] = {{QPointF(220,895),QPointF(23,91)},
                                 {QPointF(220+52,895),QPointF(31,91)},
                                 {QPointF(220,946),QPointF(24,98)},
                                 {QPointF(220+52,946),QPointF(29,98)},

                                 {QPointF(344,895),QPointF(35,91)},
                                 {QPointF(344+52,895),QPointF(43,91)},
                                 {QPointF(344,946),QPointF(37,98)},
                                 {QPointF(344+52,946),QPointF(42,98)},

                                 {QPointF(14,1020),QPointF(5,104)},
                                 {QPointF(14,1020+51),QPointF(4,111)},

                                 {QPointF(96,1020),QPointF(10,104)},
                                 {QPointF(96+52,1020),QPointF(18,104)},
                                 {QPointF(96,1020+51),QPointF(12,111)},
                                 {QPointF(96+52,1020+51),QPointF(17,111)},

                                 {QPointF(220,1020),QPointF(23,104)},
                                 {QPointF(220+52,1020),QPointF(31,104)},
                                 {QPointF(220,1020+51),QPointF(25,111)},
                                 {QPointF(220+52,1020+51),QPointF(30,111)},

                                 {QPointF(344,1020),QPointF(35,104)},
                                 {QPointF(344+52,1020),QPointF(43,104)},
                                 {QPointF(344,1020+51),QPointF(37,111)},
                                 {QPointF(344+52,1020+51),QPointF(42,111)},

                                 {QPointF(14,1144),QPointF(5,116)},
                                 {QPointF(14,1144+51),QPointF(4,112)},

                                 {QPointF(96,1144),QPointF(10,116)},
                                 {QPointF(96+52,1144),QPointF(18,116)},
                                 {QPointF(96,1144+51),QPointF(12,112)},
                                 {QPointF(96+52,1144+51),QPointF(17,112)},

                                 {QPointF(220,1144),QPointF(23,116)},
                                 {QPointF(220+52,1144),QPointF(31,116)},
                                 {QPointF(220,1144+51),QPointF(25,112)},
                                 {QPointF(220+52,1144+51),QPointF(30,112)},

                                 {QPointF(344,1144),QPointF(35,116)},
                                 {QPointF(344+52,1144),QPointF(43,116)},
                                 {QPointF(344,1144+51),QPointF(37,112)},
                                 {QPointF(344+52,1144+51),QPointF(42,112)},

                                 {QPointF(1922,346),QPointF(193,37)},
                                 {QPointF(1922,346+51),QPointF(194,43)},
                                 {QPointF(1922,478),QPointF(193,50)},
                                 {QPointF(1922,478+60),QPointF(194,58)},
                                 {QPointF(1922,628),QPointF(193,65)},
                                 {QPointF(1922,628+60),QPointF(194,73)},
                                 {QPointF(1922,778),QPointF(193,80)},
                                 {QPointF(1922,778+60),QPointF(194,88)},
                                 {QPointF(1922,928),QPointF(193,95)},
                                 {QPointF(1922,928+60),QPointF(195,103)},
                                 {QPointF(1922,1078),QPointF(193,110)},
                                 {QPointF(1922,1078+60),QPointF(194,118)},

                                 {QPointF(1749,928),QPointF(176,95)},
                                 {QPointF(1749,928+60),QPointF(177,103)},
                                 {QPointF(1749+56,928),QPointF(184,95)},
                                 {QPointF(1749+56,928+60),QPointF(183,103)},

                                 {QPointF(1621,928),QPointF(163,95)},
                                 {QPointF(1621,928+60),QPointF(164,103)},
                                 {QPointF(1621+51,928),QPointF(171,95)},
                                 {QPointF(1621+51,928+60),QPointF(170,103)},

                                 {QPointF(1749,1078),QPointF(176,110)},
                                 {QPointF(1749,1078+60),QPointF(177,118)},
                                 {QPointF(1749+56,1078),QPointF(184,110)},
                                 {QPointF(1749+56,1078+60),QPointF(183,118)},

                                 {QPointF(1621,1078),QPointF(163,110)},
                                 {QPointF(1621,1078+60),QPointF(194,118)},
                                 {QPointF(1621+51,1078),QPointF(171,110)},
                                 {QPointF(1621+51,1078+60),QPointF(170,118)},

                                 {QPointF(1496,1078),QPointF(151,110)},
                                 {QPointF(1496,1078+60),QPointF(152,118)},
                                 {QPointF(1496+51,1078),QPointF(158,110)},
                                 {QPointF(1496+51,1078+60),QPointF(157,118)},
                               };

    for (unsigned int index = 0; index < (sizeof(house1Info)/(sizeof(*house1Info[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 4);
        addBuilding(QPoint(house1Info[index][1].toPoint()),QPointF(house1Info[index][0]),QPixmap(RESOURCE_DIR + "/buildings/Rose_1home" + buildingColor + ".png"));
    }

    // Add two story houses
    QPointF house2Info[24][2] = {{QPointF(776,245),QPointF(80,31)},
                                 {QPointF(776+65,245),QPointF(86,31)},
                                 {QPointF(926,245),QPointF(95,31)},
                                 {QPointF(926+65,245),QPointF(101,31)},
                                 {QPointF(1076,245),QPointF(110,31)},
                                 {QPointF(1076+65,245),QPointF(116,31)},
                                 {QPointF(1373,371),QPointF(139,43)},
                                 {QPointF(1373+50,371),QPointF(144,43)},
                                 {QPointF(1498,371),QPointF(152,43)},
                                 {QPointF(1498+50,371),QPointF(157,43)},
                                 {QPointF(1749,371),QPointF(177,43)},
                                 {QPointF(1749+55,371),QPointF(182,43)},
                                 {QPointF(1749,520),QPointF(177,58)},
                                 {QPointF(1749+55,520),QPointF(182,58)},
                                 {QPointF(1623,520),QPointF(165,58)},
                                 {QPointF(1623+50,520),QPointF(170,58)},
                                 {QPointF(1749,822),QPointF(177,88)},
                                 {QPointF(1749+55,822),QPointF(183,88)},
                                 {QPointF(1623,822),QPointF(165,88)},
                                 {QPointF(1623+50,822),QPointF(169,88)},
                                 {QPointF(1370,970),QPointF(139,103)},
                                 {QPointF(1370+50,970),QPointF(144,103)},
                                 {QPointF(1370,1120),QPointF(139,118)},
                                 {QPointF(1370+50,1120),QPointF(144,118)},
                                };

    for (unsigned int index = 0; index < (sizeof(house2Info)/(sizeof(*house2Info[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 4);
        addBuilding(QPoint(house2Info[index][1].toPoint()),QPointF(house2Info[index][0]),QPixmap(RESOURCE_DIR + "/buildings/Rose_2home" + buildingColor + ".png"));
    }

    // Add three story house
    char buildingColor = '1' + (rand() % 4);
    addBuilding(QPoint(131,30),QPointF(1224,198),QPixmap(RESOURCE_DIR + "/buildings/Rose_3home" + buildingColor + ".png"));

    // Add office buildings
    QPointF officeInfo[17][2] = {{QPointF(767,470),QPointF(80,58)},
                                 {QPointF(767+65,470),QPointF(86,58)},
                                 {QPointF(917,470),QPointF(95,58)},
                                 {QPointF(917+65,470),QPointF(101,58)},
                                 {QPointF(767,620),QPointF(80,73)},
                                 {QPointF(767+65,620),QPointF(86,73)},
                                 {QPointF(917,620),QPointF(95,73)},
                                 {QPointF(917+65,620),QPointF(101,73)},
                                 {QPointF(1066,470),QPointF(110,58)},
                                 {QPointF(1066+65,470),QPointF(161,58)},
                                 {QPointF(1217,470),QPointF(125,58)},
                                 {QPointF(1217+65,470),QPointF(131,58)},
                                 {QPointF(1380,470),QPointF(141,58)},
                                 {QPointF(1402,620),QPointF(143,73)},
                                 {QPointF(1367,770),QPointF(140,88)},
                                 {QPointF(1216,1070),QPointF(125,118)},
                                 {QPointF(1216+65,1070),QPointF(131,118)},
                                };

    for (unsigned int index = 0; index < (sizeof(officeInfo)/(sizeof(*officeInfo[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 3);
        addBuilding(QPoint(officeInfo[index][1].toPoint()),QPointF(officeInfo[index][0]),QPixmap(RESOURCE_DIR + "/buildings/1Skyscraper" + buildingColor + ".png"));
    }

    // Add other buildings
    addBuilding(QPoint(88,85),QPointF(775,785),QPixmap(RESOURCE_DIR + "/buildings/2PostOffice.png"));
    addBuilding(QPoint(93,102),QPointF(920,935),QPixmap(RESOURCE_DIR + "/buildings/1FireStation.png"));

    QString convertString;

    for (int count = 0; count<100; count ++)
    {
        convertString.setNum((rand()%12) + 1);
        addPerson(QPixmap(RESOURCE_DIR + "/people/Dean_Person" + convertString + ".png"),buildings.at(rand() % buildings.length()));
    }

    addPerson(QPixmap(RESOURCE_DIR + "/Kit_Person.png"),buildings.at(2));
    people.last()->virus = new Virus(0,10,0,0,0,0);

}
